/**
 * @description local存储类
 * @author 盘古他爹
 */

class CacheLocal {
  setItem(key: string, value: any) {
    window.localStorage.setItem(key, JSON.stringify(value))
  }

  getItem(key: string) {
    // return JSON.parse(window.localStorage.getItem(key))
    const value = window.localStorage.getItem(key)
    if (!value) return ""
    return JSON.parse(value)
  }

  removeItem(key: string) {
    window.localStorage.removeItem(key)
  }

  clearCache() {
    window.localStorage.clear()
  }
}

export default new CacheLocal()
